<?php
class DigSearch_IndexController extends Zend_Controller_Action
{
    public function buildAction() {
        if($this->getRequest()->isPost()) {
            $index = $this->getRequest()->getParam('index', null);
            if($index != null) {
                $result = DigSearch_Service_Index::buildIndex($index);
                if($result) {
                    $cache = Dig_Service_Core::getInstance()->getCache();
                    $cache->clean(
                        Zend_Cache::CLEANING_MODE_MATCHING_TAG,
                        array('search_engine')
                    );
                    $this->_helper->json('The ' . $index . ' search index was successfully rebuilt');
                } else {
                    $this->_helper->json('There was an error rebuilding ' . $index . '.');
                }
            }
        }
    }
}
?>
